$(function() {
	var resoucesGrid = $("#distributionGrid");
	var types = {
			"SJ":"随机",
			"ZD":"指定",
	};
      
	resoucesGrid.treegrid({
		url : '/student/distributionlist',
		fit:true,
		fitColumns:true,
		singleselect:false,
		border:false,
		striped:true,//斑马色
		rownumbers:false,
		loadMsg : '数据正在加载,请耐心的等待...',
		pagination : true,// 是否显示分页栏
		idField : 'id',
		treeField : 'name',
		animate :false,
		iconCls:'icon-ok',
		columns : [ [ {
			title : '咨询师',
			field : 'name',
			width : 180,
			
		}, {
			field : 'type',
			title : '类型',
			width : 180,
			align : 'center',
			formatter:function(val){
				return types[val];
			}
		}, {
			field : 'distributionTime',
			title : '分配时间',
			width : 180,
			align : 'center',
			formatter : function(val){
				var newTime = new Date(val);
				var year = newTime.getFullYear();  //获取年
		        var month = newTime.getMonth() + 1;    //获取月
		        var day = newTime.getDate(); //获取日
		        var hours = newTime.getHours(); 
		        var minutes = newTime.getMinutes();
		        var seconds=newTime.getSeconds();
		        var time = year + "-" + month + "-" + day + "" + " " + hours + ":" + minutes + ":" + seconds;
				return time;
			}
		}, ] ],
		onLoadSuccess : function(){
			resoucesGrid.treegrid('collapseAll');
		},
		rowStyler:function(index,row){
			var time = index.distributionTime;
			
			var newTime = new Date(time);
			var year = newTime.getFullYear();  //获取年
	        var month = newTime.getMonth() + 1;    //获取月
	        var day = newTime.getDate(); //获取日
	        
	        var myDate = new Date();
	        
	        var nowyear = myDate.getFullYear();  //获取年
	        var nowmonth = myDate.getMonth() + 1;    //获取月
	        var nowday = myDate.getDate(); //获取日
			if (year == nowyear && month == nowmonth && day == nowday){
					if(index.children == null){
						return 'background-color:white;color:red;font-weight:bold;';
					}
			}
		}
	});
	
});